﻿using System.Collections;

namespace XBD.MyCastMajor
{
    internal class Program
    {

        public class Shape
        {
            public int width { get; set; }
            public int height { get; set; }

            public int x { get; set; }

            public int y { get; set; }

            public void Draw()
            {
                Console.WriteLine($"width:{width},height{height},position {x},{y}");
            }

        }

        public class Text : Shape
        {
            public int FontSize { get; set; }
            public string FontName { get; set; }

        }
        static void Main(string[] args)
        {
            var text = new Text();
            Shape shape = text;


            string[] cars = { "BMW", "VM", "Ford", "NIO" };

            var array = new ArrayList();

            array.Add("1");
            array.Add(2);
            array.Add(shape);
            array.Add(text);
            //向上转型
            var shapeList = new List<Shape>();
            shapeList.Add(new Shape());
            shapeList.Add(text);

            //向下转型
            var  shape1 = shapeList[1];

            var textList =new List<Text>();
            shapeList.ForEach(s =>
            {
                if (s is Text)
                {
                    textList.Add((Text)shape);
                }
            });
           
            Console.WriteLine(array);
        }
    }
}
